package cn.edu.lingnan.mapper;

import cn.edu.lingnan.pojo.Student;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

public class StudentMapperMysqlImpl extends SqlSessionDaoSupport implements StudentMapper{
//    private SqlSessionTemplate sqlSessionTemplate;
//
//    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
//        this.sqlSessionTemplate = sqlSessionTemplate;
//    }
//
//    @Override
//    public List<Student> selectAllStudent() {
//        StudentMapper studentMapper = sqlSessionTemplate.getMapper(StudentMapper.class);
//        return studentMapper.selectAllStudent();
//    }

//    以下是继承了SqlSessionDaoSupport以后的第二种方法
    @Override
    public List<Student> selectAllStudent() {
        StudentMapper studentMapper = getSqlSession().getMapper(StudentMapper.class);
        return studentMapper.selectAllStudent();
    }

    @Override
    public void deleteStudentBySid(String sid) {
        getSqlSession().getMapper(StudentMapper.class).deleteStudentBySid(sid);
    }
}
